﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using CCWin;
using System.IO;
namespace weiqijiance.工位配置
{
    public partial class ZBZLsetting : CCSkinMain
    {
        public ZBZLsetting()
        {
            InitializeComponent();
        }

        private void ZBZLsetting_Load(object sender, EventArgs e)
        {

            iniclass objini = new iniclass();
            string path = "";
            path = System.Windows.Forms.Application.StartupPath + path + "\\安综检仪表配置.ini";
            string path1 = string.Format(@"{0}", path);
            objini.Ini(path1);
            checkBox1.Checked = objini.ReadValue("整备质量", "启用").Trim().Contains("是")?true:false;
            txtjcsj.Text = objini.ReadValue("整备质量", "检测时间").Trim();
            checkBox3.Checked = objini.ReadValue("整备质量", "地磅").Trim().Contains("是") ? true : false;
            textBox3.Text = objini.ReadValue("整备质量", "地磅串口").Trim();

            checkBox2.Checked = objini.ReadValue("外廓尺寸", "启用").Trim().Contains("是") ? true : false;
            txtwjlj.Text = objini.ReadValue("外廓尺寸", "文件路径").Trim();
            wkcc_cj.Text = objini.ReadValue("外廓尺寸", "外廓尺寸厂家").Trim();
            txtip.Text = objini.ReadValue("外廓尺寸", "新成IP地址").Trim();
            textBox1.Text = objini.ReadValue("检测参数设置", "信息显示时间").Trim();
            checkBox4.Checked = objini.ReadValue("检测参数设置", "结果采用比例显示").Trim().Contains("是") ? true : false;
            chedpdhzbzl.Checked = objini.ReadValue("整备质量", "灯牌单行显示").Trim().Contains("是") ? true : false;
            chedpdhwkcc.Checked = objini.ReadValue("外廓尺寸", "灯牌单行显示").Trim().Contains("是") ? true : false;
        }

        private void button1_Click(object sender, EventArgs e)
        {
                
            iniclass objini = new iniclass();
            string path = "";
            path = System.Windows.Forms.Application.StartupPath + path + "\\安综检仪表配置.ini";
            string path1 = string.Format(@"{0}", path);
            objini.Ini(path1);
            objini.Writue("整备质量", "启用", checkBox1.Checked ? "是" : "否");
            objini.Writue("整备质量", "检测时间", txtjcsj.Text);
            objini.Writue("整备质量", "地磅", checkBox3.Checked ? "是" : "否");
            objini.Writue("整备质量", "地磅串口", textBox3.Text);

            objini.Writue("外廓尺寸", "启用", checkBox2.Checked ? "是" : "否");
            objini.Writue("外廓尺寸", "文件路径", txtwjlj.Text);
            objini.Writue("外廓尺寸", "外廓尺寸厂家", wkcc_cj.Text);

            objini.Writue("外廓尺寸", "新成IP地址", txtip.Text);

            objini.Writue("检测参数设置", "信息显示时间", textBox1.Text);
            objini.Writue("检测参数设置", "结果采用比例显示", checkBox4.Checked ? "是" : "否");

            objini.Writue("整备质量", "灯牌单行显示", chedpdhzbzl.Checked ? "是" : "否");
            objini.Writue("外廓尺寸", "灯牌单行显示", chedpdhwkcc.Checked ? "是" : "否");


            MessageBox.Show("完成");
            基类窗体.UploadAndDownload fupload = new 基类窗体.UploadAndDownload();
            objini.Ini(System.Windows.Forms.Application.StartupPath + "\\系统信息.ini");
            string sjcxname = objini.ReadValue("系统信息", "检测线名称");
            string sgongweiname = objini.ReadValue("系统信息", "检测工位名称");
            fupload.upload(sjcxname, sgongweiname, "安综检仪表配置.ini");
        }

        private void but_bcwjlj_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog dialog = new FolderBrowserDialog();
            dialog.Description = "请选择文件路径";

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                string foldPath = dialog.SelectedPath;
                DirectoryInfo theFolder = new DirectoryInfo(foldPath);
                string filelj = theFolder.ToString();
                if (theFolder.ToString().Length > 0)
                {
                    txtwjlj.Text = filelj + "\\";
                }
            }
        }


 
 


    }
}
